//
//  ImageStringTransfer.m
//  DailyRecord
//
//  Created by Gin on 2022/3/25.
//

#import "ImageStringTransfer.h"

@implementation ImageStringTransfer

//图片转字符串
+ (NSString *)UIImageToBase64Str:(UIImage *) image{
    NSData *data = UIImageJPEGRepresentation(image, 1.0f);
    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    return encodedImageStr;
}

//字符串转图片
+ (UIImage *)Base64StrToUIImage:(NSString *)encodedImageStr{
    NSData *decodedImageData = [[NSData alloc] initWithBase64EncodedString:encodedImageStr options:NSDataBase64DecodingIgnoreUnknownCharacters];
    UIImage *decodedImage = [UIImage imageWithData:decodedImageData];
    return decodedImage;
}

@end
